<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<c:set var="ctx" value="${pageContext.request.contextPath }" />
<%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
<jsp:include page="../inc.jsp" /> 
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		
	</head>
	<body>   
	    <script type="text/javascript">
	        var ns=0,i=0;
	        
	    	$(function(){
	    		ns = $('#notices').val();
	    		ns = parseInt((ns));
	    		i = parseInt($('#index').val());
	    		showHide();
	    		getData();
	    	});
	    	
	    	function showHide(){
	    		if((i+1)==ns){
	    			$('#nextD').hide();
	    			$('#prevD').show();
	    		}
	    		if(i==0){
	    			$('#prevD').hide();
	    			$('#nextD').show();
	    		}
	    	}
	    	
	    	function prev(){
	    		i--;
	    		if(i<0){
	    			$.messager.alert('系统警告','没有上一条通知了!','warning');
	    			return false;
	    		}else if(i==0){
	    			$('#prevD').hide();
	    			$('#nextD').show();
	    		}
	    		getData();
	    		
	    	}
	    	
	    	function next(){
	    		i++;
	    		if(i>ns){
	    			$.messager.alert('系统警告','没有下一条通知了!','warning');
	    			return false;
	    		}else if(i==ns-1){
	    			$('#prevD').show();
	    			$('#nextD').hide();
	    		}
	    		getData();
	    	}
	    	function getData(){
	    		$.ajax({
	    			type:'get',
	    			url:'${ctx}/nc/getNotice.coc?index='+i,
	    			dataType:'json',
	    			success:function(r){
	    				$('#title').html(r.title);
	    				$('#showDate').html("发布时间:"+r.showDate);
	    				$('#endDate').html("截止时间:"+r.endDate);
	    				$('#content').html(r.content);
	    				if(r.fs.length>0){
	    					var str ='';
	    					for(var i=0;i<r.fs.length;i++){
	    						var f = r.fs[i];
	    						var path = f.filePath;
	    						var oldName = f.oldName;
	    						
	    						str +='<p>'+(i+1)+''
	    						+'、<a href="${ctx}/fc/downFile.coc?path='+path+'&fileName='+oldName+'" alt="点击下载">'+oldName+'</a></p>';
	    					}
		    				$('#cc05').layout('add',{
		    					title:'附件窗口',
		    					region:'east',
		    					width:100,
		    					content:str
		    				});
	    				}else{
	    					$('#cc05').layout('remove','east');
	    				}
	    			}
	    		});
	    	}
	    </script>
	    <input type="hidden" id="notices" value="${notices}" style="display: none"/>
	    <input type="hidden" id="index" value="${i}" />
	    <div id="cc05" class="easyui-layout" fit=true>   
		    <div data-options="region:'center'" style="padding:5px;">
		    	<div style="margin: auto;width: 645px;border:1px solid #d4d4d4;height: auto;" >
		    		<table style="width: 100%;height: 99%;margin:0px 10px;">
		    			<tr height="60px">
		    				<th id="title" align="center" colspan="2" style="font-family: '楷体';
		    				font-size: 30px;color: red;font-weight: bold;">${n.title}</th>
		    			</tr>
		    			<tr height="30px">
		    				<td align="center" style="font-size: 10px;" id="showDate">发布时间:
		    				<fmt:formatDate value="${n.showDate}" pattern="yyyy-MM-dd"/>
		    				</td>
		    				<td align="center" style="font-size: 10px;" id="endDate">截止时间:
		    				<fmt:formatDate value="${n.endDate }" pattern="yyyy-MM-dd"/>
		    				</td>
		    			</tr>
		    			<tr>
		    				<td colspan="2" align="center" valign="top" id="content">${n.content }</td>
		    			</tr>
		    		</table>
		    	</div>
		    </div>
		    <div data-options="region:'south'" style="height:30px;padding: 5px;background:#eee;">
		     	<div style="float: left;" id="prevD">
		     		<a href="#" onclick="prev()">上一条</a>
		     	</div>
		     	<div style="float: right;" id="nextD">
		     		<a href="#" onclick="next()">下一条</a>
		     	</div>
		    </div>   
	    </div>
	</body>
</html>
